﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Eis51.CampanyCMS.Business.Bus;
using Eis51.CampanyCMS.Model.Bus;
using Eis51.CampanyCMS.FrameWork;
using Eis51.CampanyCMS.Model;
using Eis51.Web.Admin;

namespace Eis51.CampanyCMS.WebUI.Admin.Order
{
    public partial class PaymentApiPage : BasePage
    {
        // NewsID 0:新增/否则修改
        /// </summary>
        private string seqno
        {
            get
            {
                if (Request["seqno"] == null)
                {
                    return "0";
                }
                else
                {
                    return (string)Request["seqno"];
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (this.seqno != "0")
                {
                    Paymentapi paymentapi = PaymentapiBLL.GetInstance().Get(new Paymentapi.Key(int.Parse(this.seqno)));
                    if (paymentapi != null)
                    {
                        if (!string.IsNullOrEmpty(paymentapi.Logo ))
                        {
                            string file =string.Format( "/UpLoadFile/{0}/img/",AppContext.CurrentAdministrator.Createby)  + paymentapi.Logo;
                            string strfile = string.Format("<a target=_blank href='{0}' ><img src='{0}' width=50  height=50 border=0 ></a>", file);
                            strfile = string.Format("<a target=_blank href='{0}' ><img src='{0}' width=50  height=50 border=0 ></a>", file);
                            lbfile.Text = strfile;
                        }

                        UControl.CopyEntityToControl(this.Page.Form, paymentapi);
                    }
                }
            }
        }


        protected void btnSave_Click(object sender, EventArgs e)
        {
            Paymentapi paymentapi = null;
            if (this.seqno != "0")
            {
                paymentapi = PaymentapiBLL.GetInstance().Get(new Paymentapi.Key(int.Parse(this.seqno)));
            }
            else
            {
                paymentapi = new Paymentapi();
            }
            string file = FileListBLL.GetInstance().SaveFile(UploadFile);
            UControl.CopyControlToEntity(this.Page.Form, paymentapi);
            if (!string.IsNullOrEmpty(file))
                    paymentapi.Logo = file;
            PaymentapiBLL.GetInstance().Subimt(paymentapi);
            Response.Redirect("PaymentApiList.aspx");
        }
    }
}
